<template>
    <div class="container">
      <div class="top">
        <div class="quick-actions">
          <h2>快捷操作</h2>
          <div class="action-items">
            <div class="action-item" v-for="(item, index) in wb" :key="index" @click="handleActionClick(item.path)">
              <img :src="item.image" alt="">
              <p>{{ item.text }}</p>
            </div>
          </div>
        </div>
        <div class="notice">
          <div class="notice-header">
            <h2>通知公告</h2>
            <el-button type="text" class="publish-btn">发布公告</el-button>
          </div>
          <div class="notice-list">
            <div class="notice-item" v-for="(item,index) in tz" :key="index">
              <div class="notice-content">{{ item.text }}</div>
              <div class="notice-time">{{ item.time }}</div>
            </div>
          </div>
        </div>
      </div>
      <div class="center">
    <h2 class="section-title">考试模拟分析</h2>
    <div class="stats-container">
      <div class="stat-card" v-for="(stat, index) in stats" :key="index" :class="'stat-card-' + (index + 1)">
        <div class="stat-icon">
          <i :class="stat.icon"></i>
        </div>
        <div class="stat-content">
          <div class="stat-title">{{ stat.title }}</div>
          <div class="stat-value">{{ stat.value }}</div>
          <div class="stat-trend">
            <span :class="'trend-' + stat.trend">
              <i :class="stat.trendIcon"></i> {{ stat.trendValue }}
            </span>
            <span class="stat-period">较上月</span>
          </div>
        </div>
      </div>
    </div>
  </div>
  
  <div class="bottom">
    <div class="exam-stats">
      <h2 class="section-title">考试概况统计</h2>
      <div class="stats-grid">
        <div class="stats-card">
          <div class="stats-item">
            <div class="stats-label">累计新增考试数</div>
            <div class="stats-value">4,563</div>
            <div class="stats-compare positive">
              <i class="el-icon-top"></i> 周同比 12%
            </div>
          </div>
          <div class="stats-item">
            <div class="stats-label">本周新增考试数</div>
            <div class="stats-value">563</div>
            <div class="stats-compare positive">
              <i class="el-icon-top"></i> 周环比 18%
            </div>
          </div>
        </div>
        <div class="chart-container">
          <div class="chart-header">
            <span>近一周新增考试</span>
            <div class="time-tabs">
              <el-radio-group v-model="timeRange" size="small">
                <el-radio-button label="本周"></el-radio-button>
                <el-radio-button label="本月"></el-radio-button>
                <el-radio-button label="本季"></el-radio-button>
              </el-radio-group>
            </div>
          </div>
          <div ref="chart" class="chart" style="height: 300px;"></div>
        </div>
      </div>
    </div>
  </div>
    </div>
  </template>
  
  <script>
  import * as echarts from 'echarts';
  export default {
    data() {
      return {
        wb: [
        { text: '创建题目', image: require('../assets/images/题目 (1).png'),  path: '/main/question-bank/list'  },
        { text: '创建试卷', image: require('../assets/images/题目.png'), path: '/main/paper-manage/list'},
        { text: '创建考试', image: require('../assets/images/题目-copy-copy.png'),path: '/main/exam-manage/list' }
      ],
      tz: [
        {time:'2025-03-18 09:00', text: '【考试通知】本月进行思想品德考试'},
        {time:'2025-03-24 09:00', text: '【考试通知】本月进行马克思主义考试'},
      ],
      stats: [
        { 
          title: '总试题数', 
          value: '1,453', 
          icon: 'el-icon-collection',
          trend: 'up',
          trendIcon: 'el-icon-top',
          trendValue: '12.5%'
        },
        { 
          title: '总考试数', 
          value: '3,453', 
          icon: 'el-icon-notebook-2',
          trend: 'up',
          trendIcon: 'el-icon-top',
          trendValue: '8.2%'
        },
        { 
          title: '总考生数', 
          value: '1,453', 
          icon: 'el-icon-user',
          trend: 'down',
          trendIcon: 'el-icon-bottom',
          trendValue: '3.1%'
        },
        { 
          title: '总通过数', 
          value: '1,453', 
          icon: 'el-icon-medal',
          trend: 'up',
          trendIcon: 'el-icon-top',
          trendValue: '5.7%'
        }
      ],
      timeRange: '本周',
      dateRange: ['2023-05-12', '2023-06-20'],
      chart: null
    };
  },
  mounted() {
    this.initChart();
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$refs.chart);
      
      const option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          formatter: '{b}<br/>{a}: <span style="color:#36a3f7">{c}</span>'
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
          axisLine: {
            lineStyle: {
              color: '#DCDFE6'
            }
          },
          axisLabel: {
            color: '#606266'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#DCDFE6'
            }
          },
          splitLine: {
            lineStyle: {
              color: ['#EBEEF5'],
              type: 'dashed'
            }
          },
          axisLabel: {
            color: '#606266'
          }
        },
        series: [
          {
            name: '新增考试',
            type: 'bar',
            barWidth: '40%',
            data: [120, 132, 101, 134, 90, 230, 210],
            itemStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                { offset: 0, color: '#36a3f7' },
                { offset: 0.5, color: '#36a3f7' },
                { offset: 1, color: '#36a3f7' }
              ]),
              borderRadius: [4, 4, 0, 0]
            },
            emphasis: {
              itemStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  { offset: 0, color: '#1e88e5' },
                  { offset: 0.7, color: '#1e88e5' },
                  { offset: 1, color: '#1e88e5' }
                ])
              }
            },
            label: {
              show: true,
              position: 'top',
              color: '#36a3f7'
            }
          }
        ]
      };
      
      this.chart.setOption(option);
      window.addEventListener('resize', this.handleResize);
    },
    handleResize() {
      if (this.chart) {
        this.chart.resize();
      }
    },
    handleActionClick(path) {
      this.$router.push(path);
    },
  }
  };
  </script>
  
  <style scoped>
  .container {
    width: 100%;
    height: 100%;
    padding: 10px;
  }
  
  .top {
    height: 175px; /* 增加高度以容纳更多公告 */
    display: flex;
    gap: 20px; /* 两个区域之间的间距 */
  }
  
  .quick-actions {
    background-color: #fff;
    width: 45%;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  }
  
  .quick-actions h2 {
    text-align: left;
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
  }
  
  .action-items {
    display: flex;
    gap: 30px;
    justify-content: space-around;
  }
  
  .action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    width: 80px;
    background-color: #f5f7fa;
    padding: 10px;
    border-radius: 4px;
  }
  
  .action-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  
  .action-item img {
    width: 50px;
    height: 50px;
    margin-bottom: 8px;
  }
  
  .action-item p {
    text-align: center;
    margin: 0;
    font-size: 14px;
    color: #666;
  }
  
  .notice {
    background-color: #fff;
    width: 45%;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  }
  
  .notice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
  }
  
  .notice-header h2 {
    font-size: 18px;
    color: #333;
    margin: 0;
  }
  
  .publish-btn {
    color: #ccc;
    padding: 0;
  }
  
  .notice-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .notice-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #ebeef5;
    transition: background-color 0.3s;
  }
  
  .notice-item:hover {
    background-color: #f5f7fa;
  }
  
  .notice-content {
    flex: 1;
    text-align: left;
    color: #606266;
  }
  
  .notice-time {
    color: #909399;
    font-size: 12px;
    margin-left: 15px;
  }
  .center {
  margin-top: 20px;
  margin-right: 20px;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.section-title {
  text-align: left;
  font-size: 18px;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  padding: 20px;
  border-radius: 8px;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.stat-card-1 {
  background: linear-gradient(135deg, #f6f9ff, #e6f0ff);
  border-left: 4px solid #36a3f7;
}

.stat-card-2 {
  background: linear-gradient(135deg, #fff8f6, #ffebe6);
  border-left: 4px solid #ff6b6b;
}

.stat-card-3 {
  background: linear-gradient(135deg, #f6fff8, #e6ffee);
  border-left: 4px solid #34d399;
}

.stat-card-4 {
  background: linear-gradient(135deg, #f9f6ff, #eee6ff);
  border-left: 4px solid #9b59b6;
}

.stat-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-right: 15px;
  font-size: 24px;
}

.stat-card-1 .stat-icon {
  background-color: rgba(54, 163, 247, 0.1);
  color: #36a3f7;
}

.stat-card-2 .stat-icon {
  background-color: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
}

.stat-card-3 .stat-icon {
  background-color: rgba(52, 211, 153, 0.1);
  color: #34d399;
}

.stat-card-4 .stat-icon {
  background-color: rgba(155, 89, 182, 0.1);
  color: #9b59b6;
}

.stat-content {
  flex: 1;
}

.stat-title {
  font-size: 14px;
  color: #909399;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 4px;
}

.stat-trend {
  display: flex;
  align-items: center;
  font-size: 12px;
}

.trend-up {
  color: #f56c6c;
  margin-right: 5px;
}

.trend-down {
  color: #67c23a;
  margin-right: 5px;
}

.stat-period {
  color: #909399;
}

.bottom {
  margin-top: 20px;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.exam-stats {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

.stats-card {
  background: linear-gradient(135deg, #f6f9ff, #e6f0ff);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stats-item {
  margin-bottom: 20px;
}

.stats-item:last-child {
  margin-bottom: 0;
}

.stats-label {
  font-size: 14px;
  color: #909399;
  margin-bottom: 8px;
}

.stats-value {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 4px;
}

.stats-compare {
  font-size: 12px;
  display: flex;
  align-items: center;
}

.positive {
  color: #f56c6c;
}

.negative {
  color: #67c23a;
}

.chart-container {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.chart-header span {
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.time-tabs {
  display: flex;
  align-items: center;
}

.chart {
  width: 100%;
  height: 300px;
}
  </style>